package com.wangc.study.reflect;

import com.wangc.study.lambda.Student;

/**
 * @program: study
 * @description:
 * @author: sk_wangc
 * @create: 2020-05-26 20:26
 **/
public class CreateClassObject {


    public static void main(String[] args) throws ClassNotFoundException {
        //1、通过class.forname() 来获取class对象
        Class clazz = Class.forName("com.wangc.study.lambda.Student");
        System.out.println(clazz.getPackage());
        System.out.println(clazz.getName());
        System.out.println(clazz.getSimpleName());
        System.out.println(clazz.getCanonicalName()); //返回符合Java规范的名称

        //2、通过类名.class 来获取
        Class<Student> studentClass = Student.class;

        //3 通过对象的getClass() 来获取
        Class aClass = new Student().getClass();


        //如果是基本数据类型的话可以用下面这种方式
        Class<Integer> integerClass = Integer.class;
        System.out.println(integerClass.getName());
        System.out.println(integerClass.getCanonicalName());



    }
}
